﻿//=======================================================
// Author: Jonas Follesø <jonas@follesoe.no>
// Copyright (c) 2008
//
// Licensed under the Microsoft Public License (Ms-PL)
// A copy of the license is available at 
// http://www.opensource.org/licenses/ms-pl.html
//=======================================================

using System;
using System.Windows.Media;
using System.Collections.Generic;
using Colorful.Control.Properties;

namespace Colorful.Control.Services
{
    internal class DesignTimeColorServiceStub : IGetColors
    {
        public string LogoTooltip { get { return "Colored by Adobe Kuler"; } }

        public System.Drawing.Bitmap Logo
        {
            get { return Resources.KulerBug36; }
        }

        public IEnumerable<ColorList> SupportedLists
        {
            get
            {
                yield return ColorList.Popular;
                yield return ColorList.Random;
                yield return ColorList.Rating;
                yield return ColorList.Recent;
                yield return ColorList.Search;
            }
        }

        private Random r;

        public DesignTimeColorServiceStub()
        {
            r = new Random();
        }
        
        private Color GetRandomColor()
        {
            return Color.FromArgb(255, (byte)r.Next(0, 255), (byte)r.Next(0, 255), (byte)r.Next(0, 255));
        }

        public List<Palette> GetColors(ColorList list, int startIndex, int itemsPerPage, out int totalItems)
        {
            totalItems = 500;
            var palettes = new List<Palette>();
            for (int i = 0; i < itemsPerPage; ++i)
            {
                palettes.Add(new Palette
                {
                    Id = i + 1 + (startIndex * itemsPerPage),
                    CreatedAt = DateTime.Today,
                    Description = "Dummy design time data...",
                    Downloads = r.Next(0, 10000),
                    Rating = r.Next(0, 4),
                    Name = "Dummy Color Palette",
                    Author = "Dummy Author",
                    Color1 = GetRandomColor(),
                    Color2 = GetRandomColor(),
                    Color3 = GetRandomColor(),
                    Color4 = GetRandomColor(),
                    Color5 = GetRandomColor()
                });
            }
            return palettes;
        }

        public List<Palette> Search(string searchQuery, int startIndex, int itemsPerPage, out int totalItems)
        {            
            return GetColors(ColorList.Recent, startIndex, itemsPerPage, out totalItems);
        }
    }
}